package com.stars.empoly.vmodel

import android.app.Activity
import android.app.Application
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.stars.empoly.activity.ApplyActivity
import com.stars.empoly.activity.TechListActivity
import com.stars.empoly.model.ServiceDetails
import com.stars.empoly.utils.net.NetEngine
import com.trailer.base.base.BRepository
import com.trailer.base.base.BViewModel
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch
import kotlinx.coroutines.launch

class TechDetailsVModel(application: Application) : BViewModel<BRepository>(application) {


    var bean=MutableLiveData<ServiceDetails>()
    var id:String?=null

    fun getInfo(){

        viewModelScope.launch {
            var it=repository().lreq { NetEngine.service.platformServiceFind(id) }
            if(it.ok()){
                bean.value=it.data
            }

        }

    }

    fun toChose(){
        UiSwitch.bundle(repository().context, TechListActivity::class.java, B().putString("id",id).ok())
        (repository().context as Activity).finish()

    }

}
